﻿using Zen4SyncOrchestrator;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Zen4SyncModel;
using System.Data.SqlClient;

namespace Zen4SyncOrchestrator.Test
{
    
    
    /// <summary>
    ///Classe de test pour OrchestratorServicesTest, destinée à contenir tous
    ///les tests unitaires OrchestratorServicesTest
    ///</summary>
    [TestClass()]
    public class OrchestratorServicesTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Obtient ou définit le contexte de test qui fournit
        ///des informations sur la série de tests active ainsi que ses fonctionnalités.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [ClassInitialize()]
        public static void MyClassInitialize(TestContext testContext)
        {
            using (Zen4SyncRepositoryEntities z4sEntities = new Zen4SyncRepositoryEntities())
            {
                z4sEntities.sp_z4s_purge_database(true);
                z4sEntities.sp_z4s_insert_reference_data();
                z4sEntities.sp_z4s_create_encryption_key("Password34!");
                z4sEntities.sp_z4s_insert_test_data_Orchestrator();

            }
        }

        [ClassCleanup()]
        public static void MyClassCleanup()
        {
            using (Zen4SyncRepositoryEntities z4sEntities = new Zen4SyncRepositoryEntities())
            {
                z4sEntities.sp_z4s_purge_database(true);
            }

            using (SqlConnection sqlConnection = new SqlConnection(@"Server=localhost\SQL2008R2;Database=Zen4SyncRepository; Trusted_Connection=yes;"))
            {

                SqlCommand sqlCommand = new SqlCommand("DROP Symmetric Key Zen4SyncSymmetricKey", sqlConnection);
                sqlConnection.Open();
                sqlCommand.ExecuteNonQuery();
                sqlConnection.Close();
            }
        }

        /// <summary>
        ///Test pour StartTestSession
        ///</summary>
        [TestMethod()]
        public void StartTestSessionTest()
        {
            OrchestratorServices target = new OrchestratorServices(); 
            Guid testSessionId = new Guid("2C3C988A-675C-42D1-ACC5-D111E04D1F88"); 
            target.StartTestSession( testSessionId, "Password34!" );
            Assert.Inconclusive( "Une méthode qui ne retourne pas une valeur ne peut pas être vérifiée." );
        }
    }
}
